import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:healthy_station_flutter/utils/res_images.dart';
import 'package:provider/provider.dart';

import '../../provider/provider_login.dart';
import '../../utils/constants.dart';
import '../../utils/res_strings.dart';
import '../../utils/screen_adapter.dart';

/// 
/// @Description 
/// @Author WuJianFeng
/// @Date 2024/3/1 16:48
/// 

class LoginSelectWidget extends StatefulWidget{
  const LoginSelectWidget({super.key});

  @override
  State<StatefulWidget> createState() => _LoginSelectWidgetState();
  
}

class _LoginSelectWidgetState extends State<LoginSelectWidget>{
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(top: Adapt.pt(91), bottom: Adapt.pt(109)),
      width: Adapt.pt(534),
      height: Adapt.pt(404),
      child: Consumer<LoginProvider>(
        builder: (context, LoginProvider loginProvider, child) {
          return Stack(
            children: [
              ///身份证
              loginItem(Alignment.topLeft,"login_identity.webp",loginTypeIdentity,(clickType){
                loginProvider.setLoginType(clickType);
              }),
              ///人脸识别
              loginItem(Alignment.topRight,"login_face.webp",loginTypeFace,(clickType){
                loginProvider.setLoginType(clickType);
              }),
              ///社保卡
              loginItem(Alignment.center,"login_social.webp",loginTypeSocial,(clickType){
                loginProvider.setLoginType(clickType);
              }),
              ///电子医保
              loginItem(Alignment.bottomLeft,"login_electric.webp",loginTypeElectric,(clickType){
                loginProvider.setLoginType(clickType);
              }),
              ///账号密码
              loginItem(Alignment.bottomRight,"login_account.webp",loginTypeAccount,(clickType){
                // loginProvider.setLoginType(clickType);
                Fluttertoast.showToast(msg: sNoOpenYet);

              }),

            ],
          );
        },
      ),
    );
  }

  Widget loginItem(Alignment alignment, String imgName, int loginType, Function(int) clickType){
    return Positioned(
      child: Align(
        alignment: alignment,
        child: InkWell(
            onTap: (){
              clickType(loginType);
            },
            child: ImageUtils.getImgWithSize(imgName,203,198)
        ),
        
      ),
    );
  }

}
 
 